import Vue from "vue";
import Vuex from "vuex";

Vue.use(Vuex);

let correctApi = "..";
try {
    let localUrl = "http://localhost:8080,http://192.168.8.54:8080,http://192.168.8.88:8080,http://192.168.8.88:8081,";
    if (
        window.location.origin &&
        localUrl.indexOf(window.location.origin) != -1
    ) {
        correctApi = "/api"
    } else {
        correctApi = "http://testapi.link.jzsoft.cn"
    }
    console.log(correctApi)
} catch (error) {
    console.log(error)
}

export default new Vuex.Store({
    state: {
        apiUrl: correctApi,
    },
    mutations: {
        getApiUrl(state, key) {
            state.apiUrl = key
        },
    },
    actions: {},
    modules: {}
});